package com.its.web;

import com.its.client.UserServiceClient;
import com.its.service.OrderService;
import com.its.util.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 朱厚强
 * @since 2024年01月17日
 */
@RestController
@RequestMapping("/order")
@RefreshScope // 配置文件热更新
@Slf4j
@Api("order-api")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private DiscoveryClient discoveryClient;
    @Autowired
    private UserServiceClient userServiceClient;

    @GetMapping("getById/{id}")
    public Result getById(@PathVariable String id){
        return orderService.getByIds(id);
    }

    @GetMapping("/query")
    public String queryOrder() {
        // 查询商品
        orderService.queryGoods();
        // 查询订单
        System.out.println("查询订单");
        return "查询订单成功";
    }

    @GetMapping("/save")
    public String saveOrder() {
        // 查询商品
        orderService.queryGoods();
        // 新增订单
        System.err.println("新增订单");
        return "新增订单成功";
    }


}
